/*
 *  Acronym                : TrmI2c.h
 *  Name of Module         : TrmI2c.a
 *  Product/Project        : Rhapsody for TriMedia
 *  12NC                   :
 *  Group number           : 885540
 *  Creation date          : 1999-03-17
 *  Modification date      : 2001-07-31
 *  Related documents      : CTB554-98-B155
 *  Program language       : C
 *  Documentation language : English
 *  Status                 : Preliminary
 *  Author(s)              : P.J. Zander
 *
 *                Copyright (C) Philips Electronics N.V. 1999-2001
 *                   CFT Centre for Industrial Technology
 *                             Industrial Vision
 *                        Eindhoven - The Netherlands
 *
 *       All rights are reserved. Reproduction in whole or in part is
 *           prohibited without the written consent of the author.
 */

/*
 *  Description:	
 *    Export header file of Subsystem: I2c
 *
 */

#ifndef _TRMI2C_H
#define _TRMI2C_H

/*
 *----------------------------------------------------------------------------
 *  Module Includes
 *----------------------------------------------------------------------------
 */

#include "TrmBases.h"

/*
 *----------------------------------------------------------------------------
 * C++ Define
 *----------------------------------------------------------------------------
 */

#ifdef __cplusplus
extern "C" {
#endif

/*
 *----------------------------------------------------------------------------
 * Exported Errors
 *----------------------------------------------------------------------------
 */
 
#define TRM_I2C_ERROR_NONE                   (0)
#define TRM_I2C_ERROR_NOT_OPENED             (TRM_I2C_ERROR_BASE+0x00)
#define TRM_I2C_ERROR_PARAMETER              (TRM_I2C_ERROR_BASE+0x01)
#define TRM_I2C_ERROR_CREATE_SEMAPHORE       (TRM_I2C_ERROR_BASE+0x02)
#define TRM_I2C_ERROR_SEMAPHORE_TIMEOUT      (TRM_I2C_ERROR_BASE+0x03)
#define TRM_I2C_ERROR_EVENT_TIMEOUT          (TRM_I2C_ERROR_BASE+0x04)

#define TRM_I2C_ERROR_NO_ACK_SLAVE_ADDRESS   (TRM_I2C_ERROR_BASE+0x10)
#define TRM_I2C_ERROR_NO_ACK_SLAVE_DATA      (TRM_I2C_ERROR_BASE+0x11)

/*
 *----------------------------------------------------------------------------
 * Exported Defines
 *----------------------------------------------------------------------------
 */
 
#define TRM_DEBUG_OFF                  (0x00)
#define TRM_DEBUG_ALL                  (0xFF)
#define TRM_DEBUG_EXPORTED_CALL        (0x01)
#define TRM_DEBUG_EXPORTED_INTERNAL    (0x02)
#define TRM_DEBUG_FUNCTION_CALL        (0x04)
#define TRM_DEBUG_FUNCTION_INTERNAL    (0x08)
#define TRM_DEBUG_ISR                  (0x10)

/*
 *----------------------------------------------------------------------------
 * Exported Function Prototypes
 *----------------------------------------------------------------------------
 */

    void TrmI2cDebug(
        int mode);
        
    int TrmI2cOpen(
        unsigned int   intPriority,
        char          *semName,
        unsigned long  semTimeout,
        unsigned int   ackEvent,
        unsigned long  ackTimeout);

    int TrmI2cRead(
       unsigned int  address,
       unsigned int  nBytes,
       unsigned int *data);
    
    int TrmI2cReadBlock(
        unsigned int  address,
        unsigned int  nBytes,
        unsigned char data[]);

    int TrmI2cWrite(
       unsigned int address,
       unsigned int nBytes,
       unsigned int data);

    int TrmI2cWriteBlock(
        unsigned int  address,
        unsigned int  nBytes,
        unsigned char data[]);

/*
 *----------------------------------------------------------------------------
 */

#ifdef __cplusplus
}
#endif

#endif
